//
//  DCheadView.m
//  shusheng
//
//  Created by rimi on 16/7/16.
//  Copyright © 2016年 yuying. All rights reserved.
//

#import "DCheadView.h"

@implementation DCheadView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self initializeUserInterface];
    }
    return self;
}


- (void)initializeUserInterface{
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).with.offset(10);
        make.left.equalTo(self).with.offset(10);
        make.right.equalTo(self).with.offset(-10);
        make.height.mas_equalTo(25);
    }];
    
    [self addSubview:self.nameImageView];
    [self.nameImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).with.offset(5);
        make.left.equalTo(self).with.offset(10);
        make.width.mas_equalTo(0.1 * SCREEN_WIDTH);
        make.height.mas_equalTo(0.1 * SCREEN_WIDTH);
    }];
    
    [self addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).with.offset(5);
        make.left.mas_equalTo(self.nameImageView.mas_right).with.offset(5);
        make.right.mas_equalTo(self.mas_centerX).with.offset(5);
        make.height.mas_equalTo(0.1 * SCREEN_WIDTH /2);
    }];
    
    [self addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameLabel.mas_bottom).with.offset(0);
        make.left.mas_equalTo(self.nameImageView.mas_right).with.offset(5);
        make.right.mas_equalTo(self.mas_centerX).with.offset(5);
        make.height.mas_equalTo(0.1 * SCREEN_WIDTH /2);
    }];
    
    [self addSubview:self.detailLabel];
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameImageView.mas_bottom).with.offset(5);
        make.left.equalTo(self).with.offset(10);
        make.right.equalTo(self).with.offset(-10);
        make.bottom.equalTo(self).with.offset(-10);
    }];
    
}


#pragma mark -- Getters
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont boldSystemFontOfSize:18];
//        _titleLabel.backgroundColor = [UIColor orangeColor];
//        _titleLabel.text = @"asdasasasa";
    }
    return _titleLabel;
}

- (UIImageView *)nameImageView{
    if (!_nameImageView) {
        _nameImageView = [[UIImageView alloc] init];
        _nameImageView.layer.cornerRadius = 3;
//        _nameImageView.backgroundColor = [UIColor orangeColor];
        
    }
    return _nameImageView;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
//        _nameLabel.text = @"小明";
        [_nameLabel setTextColor:[UIColor blueColor]];
//        _nameLabel.backgroundColor = [UIColor orangeColor];
    }
    return _nameLabel;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
//        _timeLabel.backgroundColor = [UIColor lightGrayColor];
        _timeLabel.font = [UIFont systemFontOfSize:13];
//        _timeLabel.text = @"1楼 今天 15：12";
    }
    return _timeLabel;
}


- (UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc] init];
//        _detailLabel.backgroundColor = [UIColor greenColor];
        _detailLabel.numberOfLines = 3;
        
    }
    return _detailLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
